#ifndef __INCcronManagerh
#define __INCcronManagerh

#include <string>
#include <vector>
#include <memory>
#include <chrono>
#include <objbase.h>
#include <timer.h>
#include <unordered_map>

struct CronTask 
{
    std::string taskName;
    std::string cronExpr;
    std::string taskPath;
    int lastExecMinute;
    int lastExecHour;
    int lastExecDay;
};

using CronTaskMap = std::unordered_map<std::string, CronTask>;
class CronManager : public objbase 
{
private:
    CronTaskMap m_jobs;
    std::atomic<bool> m_isRunning{false};
    
public:
    DECLARE_CTOR_DTOR(CronManager);
    OBJBASE_EXTERN_MEMBER_IMPL();
    void cronCheckJobs();

private:
    DISABLE_COPY_CLASS(CronManager);
    PROCESS_DESC(sysShutdown);
    PROCESS_DESC(addJob);
    PROCESS_DESC(removeJob);
    PROCESS_DESC(jobList);
    STATUS dump(TextTable& outMsg, bool isDump = false);
};

#endif
